<template>
  <div id="Incubation_application">
    <div class="Incubation_application_top">
      <span>温馨提示：如您已提交申请，请耐心等待评审结果，勿重复提交！</span>
    </div>
    <div class="Incubation_application_bottom">
      <div class="Incubation_application_tips">
        <img src="../../../assets/icon/finger-down.png" alt="" />
        <span>请如实填写入孵申请信息！</span>
      </div>
      <el-form
        :model="form"
        :label-position="labelPosition"
        label-width="100px"
      >
        <el-form-item label="申请人:">
          <el-input :disabled="true" v-model="form.pricipalName"></el-input>
        </el-form-item>
        <el-form-item label="团队名称:">
          <el-input :disabled="true" v-model="form.teamName"></el-input>
        </el-form-item>

        <el-form-item label="路演批次:">
          <el-select
            v-model="form.joinTitle"
            clearable
            placeholder="请选择路演批次"
          >
            <el-option
              v-for="item in options"
              :key="item.id"
              :label="item.joinTitle"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <div class="Incubation_application_Submit">
          <el-button @click="Submit_form">提交</el-button>
          <el-button @click="empty_form">取消</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  props: {},
  components: {},
  data() {
    return {
      labelPosition: "right",
      form: {
        pricipalName: " ",
        teamName: "xxx团队",
        joinTitle: "",
      },
      options: [],
    };
  },
  methods: {
    async Submit_form() {
      const self = this;
      const { data: res } = await this.$http({
        headers: { "Content-Type": "application/json;charset=UTF-8" },
        method: "post",
        url: "/api/apply/addApplyJoin",
        params: { joinInfoId: self.form.joinTitle },
      });
      // console.log(this.form.joinTitle);
      console.log(res);
      if (res.code != 200) {
        this.$message.error(res.msg);
        return;
      }

      this.$message.success(res.msg);
      this.form.joinTitle = "";
    },
    empty_form() {
      this.form.joinTitle = "";
    },

    keyDown(e) {
      //如果是回车则执行登录方法
      if (e.keyCode == 13) {
        this.Submit_form();
        return;
      }
    },
  },
  async created() {
    this.form.pricipalName = window.localStorage.getItem("name");
    const { data: res } = await this.$http({
      headers: { "Content-Type": "application/json;charset=UTF-8" },
      method: "get",
      url: "/api/apply/getJoinInfos",
    });
    this.options = res.msg;
  },

  mounted() {
    //绑定事件
    window.addEventListener("keydown", this.keyDown);
    this.form.teamName = window.sessionStorage.getItem("TeamName");
  },
  destroyed() {
    window.removeEventListener("keydown", this.keyDown);
  },
};
</script>

<style lang="less">
#Incubation_application {
  // background-color: rgb(167, 19, 19);
  position: relative;
  height: 90%;
  width: 90%;
  margin: auto;
  display: flex;
  flex-direction: column;
}
.Incubation_application_top {
  margin-top: 10px;
  display: flex;
  // width: 100%;
  height: 10%;
  // background-color: rgb(212, 24, 24);

  span {
    border-radius: 10px;
    width: 900px;
    background-color: rgb(229, 240, 255);
    margin: auto;
    text-align: center;
    height: 50px;
    line-height: 50px;
  }
}
.Incubation_application_bottom {
  margin: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 10px rgba(0, 0, 0, 0.04);
  height: 100%;

  width: 98%;
  display: flex;
  flex-direction: column;
  .el-form {
    display: flex;
    flex-direction: column;

    height: 100%;
    // background-color: rgb(99, 48, 48);
    width: auto;

    margin: auto;
    margin-top: 30px;
    .el-form-item {
      display: flex;
      flex-direction: row;
      height: 50%;

      .el-form-item__label {
        font-size: 20px;
        height: 60px;
        line-height: 60px;
        font-weight: bold;
        width: 150px !important;
        text-align: center;

        float: right;
      }
      .el-input {
        width: 700px;

        .el-input__inner {
          height: 60px;
          font-size: 19px;
        }
      }
    }
  }
}
.Incubation_application_tips {
  height: 30px;
  margin: 15px auto;
  display: flex;
  width: 250px;
  img {
    height: 30px;
    width: 30px;
    line-height: 50px;
  }
  span {
    width: 200px;
    height: 30px;
    line-height: 30px;
    margin-left: 15px;
  }
}

.Incubation_application_Submit {
  height: 80px;
  width: auto;
  display: flex;
  margin: 5% auto;
  // margin-top: 5%;
  button {
    width: 200px;
    border: none;
  }
  button:nth-child(1) {
    background-color: rgb(0, 110, 255);
    color: #fff;
    font-size: 20px;
    font-weight: bolder;
  }
  button:nth-child(2) {
    background-color: rgb(242, 242, 242);
    margin-left: 150px;
    font-size: 20px;
  }
}

.Settlement_agreement_bottom {
  display: flex;
}
</style>